
<template>
    <!-- 搜索 -->
    <a-row>
        <a-input-search v-model:value="searchKey" placeholder="请输入数据信息" style="width: 200px; margin-bottom: 10px;"
            @search="onSearch()" />
    </a-row>
    <!-- 金属扶正器信息 -->
    <a-table :rowKey="(record) => record.alignmentModelId" :row-selection="rowSelection" :dataSource="dataSource"
        size="small" :columns="columns" bordered :scroll="{ x: 1000 }" :pagination="false">
        <template #bodyCell="{ column, text, record }">
            {{ text }}
        </template>
    </a-table>
    <!-- 分页 -->
    <AntdZh>
        <a-pagination v-model:current="query.pageNum" v-model:pageSize="query.pageSize" :total="total" @change="getList" />
    </AntdZh>
</template>
<script setup>
import { ref } from 'vue';
import { cloneDeep } from 'lodash-es';
import { queryList } from "@/api/tool/mental";
import useApp from "@/hooks";
const { $, proxy } = useApp();
const emit = defineEmits(["mentalSelection",]);
const data = reactive({
    form: {}
});
const { form } = toRefs(data);
const dataSource = ref([]);
const total = ref(1)
// 定义表格列配置
const columns = [
    {
        title: '型号',
        dataIndex: 'alignmentModelId',
        key: 'alignmentModelId',
        fixed: 'left',
        width: 150
    },
    {
        title: '名称',
        dataIndex: 'alignmentName',
        key: 'alignmentName',
        width: 150
    },
    {
        title: '类型',
        dataIndex: 'alignmentType',
        key: 'alignmentType',
        width: 100
    },
    {
        title: '适用仪器外径(mm)',
        dataIndex: 'applicableOuterDiameter',
        key: 'applicableOuterDiameter',
        width: 150
    },
    {
        title: '适用井眼',
        dataIndex: 'applicableWellBore',
        key: 'applicableWellBore',
        width: 150
    },
    {
        title: '接头类型',
        dataIndex: 'jointType',
        key: 'jointType',
        width: 250
    },
    {
        title: '扶正力',
        dataIndex: 'rightingForce',
        key: 'rightingForce',
        width: 150
    },
    {
        title: '工具使用长度(mm)',
        dataIndex: 'usageLength',
        key: 'usageLength',
        width: 150
    },
];
const searchKey = ref();
const query = ref({ pageNum: 1, pageSize: 10, sortBy: 'id', searchKey: '' });

const rowSelection = {
    onChange: (selectedRowKeys, selectedRows) => {
        console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
        emit("mentalSelection", selectedRows)
    },
    getCheckboxProps: record => ({
        alignmentModelId: record.alignmentModelId
    }),
};


/** 查询井列表 */
function getList() {
    queryList(query.value).then((response) => {
        dataSource.value = response.content;
        total.value = response.totalElements;
    });
}
getList();

/** 搜索按钮操作 */
function onSearch() {
    query.value.searchKey = searchKey;
    getList();
}

/** 表单重置 */
function reset() {
    searchKey.value = '';
    query.value = {
        pageNum: 1, pageSize: 10, sortBy: 'id',
        searchKey: '',
    }
    getList();
}

/** 提交按钮 */
function submitItem() {

}
</script>
  